<?php
include_once $_SERVER['DOCUMENT_ROOT'].'/phorm/database/core/DatabaseColumn.php';

class PrimaryKey extends DatabaseColumn
{	
	public $auto_increment;
	public $options;
	
	public function __construct(IDatabaseRecord &$object, $field_type = 'integer', $length = 11, $auto_increment = true)
	{
		// previoulsy was using debug_backtrace()
		// but we found an issue when (we think) php was running as CGI.  The ['object']
		// key was not being passed.
		// signature was:
		// public function __construct($length = null, $defaultValue = null)
		// $this->model was being set via:
		// $tmp =  debug_backtrace();
		// $this->model        = &$tmp[1]['object'];
		
		$this->model               = $object;
		
		$this->field_type          = $field_type;
		
		if($field_type == 'uuid')
			$this->length          = 36;
		else 
			$this->length          = $length;
		
		$this->auto_increment      = $field_type == 'integer' ? $auto_increment : false;
		$this->options             = $this->auto_increment ? "UNSIGNED" : "NOT NULL";
		
	}
}
?>
